# - Find libmosquitto
# Find the native libmosquitto includes and libraries
#
#  MOSQUITTO_INCLUDE_DIR - where to find mosquitto.h, etc.
#  MOSQUITTO_LIBRARIES   - List of libraries when using libmosquitto.
#  MOSQUITTO_FOUND       - True if libmosquitto found.

macro(find_mosquitto)
  if (NOT MOSQUITTO_INCLUDE_DIR)
    find_path(MOSQUITTO_INCLUDE_DIR mosquitto.h ${MOSQUITTO_ROOT}/include)
  endif()
  if (NOT MOSQUITTO_LIBRARY)
    find_library(
      MOSQUITTO_LIBRARY
      NAMES mosquitto mosquittopp PATHS ${MOSQUITTO_ROOT}/lib)
  endif()
  
  include(FindPackageHandleStandardArgs)
  
  find_package_handle_standard_args(
    MOSQUITTO DEFAULT_MSG
    MOSQUITTO_LIBRARY MOSQUITTO_INCLUDE_DIR)
  
  message(STATUS "libmosquitto include dir: ${MOSQUITTO_INCLUDE_DIR}")
  message(STATUS "libmosquitto: ${MOSQUITTO_LIBRARY}")
  set(MOSQUITTO_LIBRARIES ${MOSQUITTO_LIBRARY})
  
  mark_as_advanced(MOSQUITTO_INCLUDE_DIR MOSQUITTO_LIBRARY)

  if (NOT MOSQUITTO_FOUND)
    message(FATAL_ERROR "mosquitto not found")
  endif()

endmacro()
